﻿using System;
using System.Web.Hosting;
using OpenWaves.Web.Controls;
using OpenWaves.Web.ImageTransformations;

namespace OpenWaves.Web.Tests
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            HostingEnvironment.RegisterVirtualPathProvider(new ReferencedProjectVirtualPathProvider("OpenWaves.Web"));

            var imageTransformationService = new WebImageTransformationService();
            var transformationModuleImplementation = new WebImageTransformationModuleImplementation(imageTransformationService);
            var responsiveTransformationModuleImplementation = new ResponsiveWebImageTransformationModuleImplementation(imageTransformationService);

            ServiceLocator.SetResolver(new BasicResolver()
                .Register<IWebImageTransformationService>(transformationModuleImplementation)
                .Register<IResponsiveWebImageTransformationService>(responsiveTransformationModuleImplementation)
                .Register<IWebImageTransformationModuleImplementation>(new CompositeWebImageTransformationModuleImplementation(
                    transformationModuleImplementation,
                    responsiveTransformationModuleImplementation)));
        }
    }
}